angular.module('market-detail', [])

.controller 'MarketDetailCtrl', ($scope, $state,$localStorage, $http, $ionicHistory, $stateParams, newAddress,showToast, wfCache,$ionicViewSwitcher,$ionicPopup,userData) ->
    $scope.$storage = $localStorage
    console.log $localStorage['goodItem']
    $scope.getPro = ->
        backState = $ionicHistory.backView()
        if backState.stateName == 'tab.market-referencepro' || backState.stateName == 'tab.referencepro'
            return true
        else
            return false
    $scope.isupkpro = $scope.getPro()
    console.log $ionicHistory.backView().stateName
    _.extend $scope,
        goAddypk:->
            console.log $localStorage['goodItem']
            if $ionicHistory.backView().stateName == 'tab.market-home'
                $state.go 'tab.goods-addypk-home', {obj:$localStorage['goodItem']}
            else if $ionicHistory.backView().stateName == 'tab.market-orders'
                $state.go 'tab.goods-addypk-orders', {obj:$localStorage['goodItem']}
            else if $ionicHistory.backView().stateName == 'tab.market-purchase'
                $state.go 'tab.goods-addypk-purchase', {obj:$localStorage['goodItem']}
            else
                $state.go 'tab.goods-addypk', {obj:$localStorage['goodItem']}
        goBack: ->
            $ionicHistory.goBack()


